
import { ItemModel } from 'core/model/itemModel'
import utils from 'core/utils/utils'
import { gameConfigHandle} from 'core/config/gameConfig'


class ItemHandle {
    create({tid, stack, pos, hp}: any): ItemModel {
        let itemConfig = gameConfigHandle.configByID[tid]
        if (!itemConfig) {
            console.log(tid)
            return null
        }
        stack = stack || 1
        
        let item = new ItemModel({
            tid: tid || 0,
            stack: stack || 1,
            pos: pos || 0,
            hp: hp || itemConfig.maxHp || 0,
            new: true
        })
        return item
    } 
}

let itemHandle = new ItemHandle()
export default itemHandle

